Research on the Improvement of Semi-Global Matching Algorithm for Binocular Vision Based on Lunar Surface Environment

The low light conditions, abundant dust, and rocky terrain on the lunar surface pose challenges for scientific research. To effectively perceive the surrounding environment, lunar rovers are equipped with binocular cameras. In this paper, with the aim of accurately detect obstacles on the lunar surface under complex conditions, an Improved Semi-Global Matching (I-SGM) algorithm for the binocular cameras is proposed. The proposed method first carries out a cost calculation based on the improved Census transform and an adaptive window based on a connected component. Then, cost aggregation is performed using cross-based cost aggregation in the AD-Census algorithm and the initial disparity of the image is calculated via the Winner-Takes-All (WTA) strategy. Finally, disparity optimization is performed using left–right consistency detection and disparity padding. Utilizing standard test image pairs provided by the Middleburry website, the results of the test reveal that the algorithm can effectively improve the matching accuracy of the SGM algorithm, while reducing the running time of the program and enhancing noise immunity. Furthermore, when applying the I-SGM algorithm to the simulated lunar environment, the results show that the I-SGM algorithm is applicable in dim conditions on the lunar surface and can better help a lunar rover to detect obstacles during its travel.


Introduction
The lunar surface is topographically complex due to the presence of numerous rocks and craters, which present significant challenges for the scientific investigations carried out by lunar rovers. These lunar rovers must efficiently undertake crucial tasks, including obstacle detection, path planning, and obstacle avoidance. However, the low level of illumination on the lunar surface leads to poor contrast in the captured images, which causes a loss of image details, thereby hindering further image processing [1,2]. Therefore, the lunar rover must carefully select its sensor. Binocular cameras are most cost-effective sensors and can provide rich and high-dimensional semantic information for obstacle detection tasks, while having a lower power consumption [3][4][5][6][7] and better assisting the lunar rover with its exploration mission.
Binocular vision [8,9] is a significant subfield in machine vision, where 2D planar image data are acquired by two cameras and extended to a 3D scene using computer vision processing. Binocular vision relies on stereo matching to determine disparity by matching the equivalent pixel locations in an image pair. The precision of the final reconstruction is directly proportional to the quality of the stereo matching result. With the gradual development of research in this field, stereo matching is being widely used in 3D reconstruction [10,11], industrial inspection [12][13][14][15], UAV [16,17], remote sensing [18,19], and intelligent control of robots [20][21][22].
Scharstein et al. [23] divided stereo matching algorithms into two categories: local stereo algorithms and global stereo algorithms. The local stereo matching algorithm determines disparity by comparing image blocks of the same size in the left and right views. Although the local stereo matching algorithm has a low computational complexity, it has poor matching effects in low texture areas, repeated texture areas, disparity discontinuities, and occlusion areas. It is also prone to mismatching. The global stereo matching algorithm calculates disparity by constructing a global energy function and minimizing it. Although the global stereo matching algorithm has a high matching accuracy, it is computationally intensive, resulting in a low algorithm rate, so it is not suitable to use the global stereo matching algorithm in instances with high real-time requirements, and cannot be implemented in hardware. Based on the above problems, Hirschmuller [24] proposed a Semi-Global Matching (SGM) algorithm, which can meet the requirements of both the high accuracy and efficiency of the algorithm. The SGM algorithm has become a major part of scholars' research in recent years.
To improve the robustness of aggregation, many researchers have fused SGM algorithms with other algorithms. Guo et al. [25] proposed a modified SGM algorithm based on the fast Census transform. Zhang et al. [26] proposed a PatchMatch Semi-Global Matching (PMSGM) algorithm that significantly reduces the number of candidate disparity through a PatchMatch spatial propagation scheme. Pan et al. [27] proposed an improved Census transform algorithm based on the sequence template. Zhang et al. [28] used the Census transform and adaptive window to calculate cost simultaneously, and determined the size and shape of the cost calculation window by judging the gradient size of the matching points. The SGM algorithm often has similar texture and fringe artifacts due to the lack of interaction between adjacent scanlines. In response, Liu et al. [29] propose a method of layering and precise positioning of the disparity search space using SGM pyramids and local invariant features to improve computational efficiency, reduce memory occupation, and reduce the influence of similar textures. Bu et al. [30] introduced a local edge-aware filtering method in SGM to enhance the interaction of adjacent scanlines and avoid fringe artifacts. Deng et al. [31] combined multi-path cost aggregation and cross-scale cost aggregation (CSCA) to propose an SGM-MSIF algorithm based on multi-scale information fusion (MSIF). In order to achieve the high real-time performance of SGM algorithms, many scholars have combined SGM algorithms with FPGA. Sawant et al. [32] show the design and implementation of a stereo-vision system, which is based on an FPGA implementation of More Global Matching (MGM). MGM is a variant of SGM. To reduce the effect of noise on matching accuracy, researchers usually combine SGM algorithms with image filtering methods, such as derivative filtering [33,34], bilateral filtering [35], and median filtering [36].
Although all the above algorithms achieve better accuracy, they still have the problems of excessive computation and time consumption in practical situations. In the case of the same texture large area, the matching effect and accuracy obtained by these algorithms are also less satisfactory and poor. To address the above problems, this paper proposes the improved SGM (I-SGM) algorithm, which combines an adaptive window based on connected components and an improved Census algorithm. Firstly, the Census algorithm is used in the cost calculation instead of the original mutual information-based cost calculation. The improved Census algorithm reduces the influence of the window center pixel value on the Census algorithm, which effectively reduces the influence of noise on the algorithm and improves noise immunity. Second, since the matching window in the traditional Census algorithm is a fixed rectangular window, which will affect the matching efficiency of the algorithm, this paper proposes an adaptive window based on the connected components, which can be adaptive to obtain the best matching window for different regions of the image and reduce the running time of the algorithm. Finally, the accuracy of the algorithm is improved by using the cross-based cost aggregation in the cost aggregation stage. In order to verify the effectiveness of the I-SGM algorithm, the experimental analysis of the image pairs from the existing dataset is conducted. The experimental results show that the I-SGM algorithm can not only improve the matching speed and accuracy, but also has certain noise immunity.

Semi-Global Matching Algorithm
The Semi-Global Matching algorithm uses the framework of the global algorithm to search through all regions of the image and a global optimization theory approach to estimate disparity [24]. The main principle of the algorithm is to establish a global energy function and use the results of aggregating multiple 1D paths to calculate the optimal solution for minimizing the energy function. The algorithm is divided into the following steps.

1.
Pixelwise Matching Cost Calculation: Mutual information (MI) [37] is used to characterize the magnitude of the amount of information shared by two images, which can be used as a measure of similarity between two images. This method is more robust to illumination changes as a pixel similarity metric and is an excellent cost function. The definition of MI is: where I 1 is the reference image; I 2 is the matched image; p is a pixel point; I 1p and I 2p are the grayscale values of the left and right images, respectively; mi I 1 ,I 2 is the mutual information calculated for a corresponding point of I 1 and I 2 ; i and k are the two grayscales of the data items involved in the calculation; h I 1 and h I 2 are the entropy of I 1 and I 2 , respectively; and h I 1 ,I 2 is the joint entropy of the two images. The matching cost CMI for a point p based on mutual information is: where f D (I m ) is the base image, I b is the matched image, I bp is the intensity of the base image pixel p and I mq is the suspected correspondence of the matched image, and q denotes the eponymous point of pixel p.

Cost Aggregation
The matching cost in the previous section is susceptible to mismatches and noisy points. Therefore, in order to add smoothness constraints in the cost aggregation, the penalty function is considered to be constructed using the neighboring disparities. A global energy function E(D) is designed and used to integrate the matching cost and smoothness constraints.
where N p is the matching window and P 1 and P 2 are the penalty factors. The first term of the formula is the data term, which is the sum of the matching cost of all pixels under the disparity map D. The second and third terms are smoothing terms. The second term represents a penalty for cases where the difference in disparity between pixel p and its neighborhood pixel q is one pixel, adding a constant penalty value P 1 . The third term indicates that if the disparity between pixel p and neighboring pixel q is greater than one pixel, a constant penalty value P 2 is added, and P 2 > P 1 .
In order to convert the global energy function value to a fixed function energy value, path cost aggregation is performed. The 1D aggregation of the matching cost on all paths around a pixel yields the path generation value under the path, and the sum of all path generation values is the matching generation value after aggregation for that pixel. The path cost of a pixel p along a particular path r is calculated as shown in Equation (6).
where r refers to the path direction of pixel p and d is the disparity value of pixel p. L r (p,d) is the cost of matching when pixel p has value d and path direction r. p − r indicates the last matched pixel point when the path direction is r.

Disparity Computation
The Winners-Takes-All algorithm (WTA) [38] is usually used to calculate the disparity. The disparity corresponding to the smallest generation value is chosen as the optimal disparity among all the generation values for a given pixel. If scene accuracy is required, the disparity is calculated by fitting a quadratic curve to the neighboring costs at the neighboring disparity. A left-right consistency check can also be used to determine if there are masked areas and mismatched areas.

Disparity Refinement
The disparity image resulting from the above steps may still contain errors or invalid areas. These problems can be solved via the post-processing of the disparity image. If there are outliers in the disparity image, a method of removing peak disparity can be used. To solve the problem of disparity discontinuities, leading to boundary errors, intensityconsistent disparity selection can be performed on disparity images. When the disparity map has holes, it is necessary to obtain a dense disparity map by interpolation.

Census Algorithm
The basic principle of the Census algorithm is to create a window centered on a reference pixel point and use this window as a filter to traverse the matched image one by one. The entire filter makes the neighboring pixels form a binary string, and comparing the distance between the two strings is the value of the match between the reference pixel point and the matching pixel point [39].
The Census transformation formula is as follows: where I(p) is the gray value of the pixel at the center point of the window, and I(q) is the gray value of the remaining points except the center point. After setting the fixed window, all 1s or 0s are shot in the window into a string of bits. By comparing the bit strings of a pixel in two figures, the Hamming distance similarity measure can be used to derive the cost of matching as follows: Although the Census transform can accurately correct the grayscale deviation caused by uneven lighting, the Census transformation only uses a 0/1-bit byte string to represent the grayscale difference between two pixel points, making the feature descriptor too single. Additionally, when the grayscale changes sharply in the adjacent window, or there is the same repeat region, the matching cost obtained by the Census transformation does not reflect the similarity of the image well.

Improved Semi-Global Matching (I-SGM) Algorithm
To improve the matching speed and accuracy of the algorithm, the I-SGM algorithm is proposed. For cost calculation, an improved Census algorithm is employed. The Census transform's reference pixel is reset, and the adaptive transformation window based on the connected components is added into the improved Census algorithm. Cross-based cost aggregation is used in the cost aggregation. The WTA algorithm is used to calculate the initial disparity in the disparity computation. The initial disparity is then optimized using the left-right consistency test and disparity filling to obtain the final disparity map. The flow chart of the I-SGM algorithm is shown in Figure 1. the same repeat region, the matching cost obtained by the Census transformation does not reflect the similarity of the image well.

Improved Semi-Global Matching (I-SGM) Algorithm
To improve the matching speed and accuracy of the algorithm, the I-SGM algorithm is proposed. For cost calculation, an improved Census algorithm is employed. The Census transform's reference pixel is reset, and the adaptive transformation window based on the connected components is added into the improved Census algorithm. Cross-based cost aggregation is used in the cost aggregation. The WTA algorithm is used to calculate the initial disparity in the disparity computation. The initial disparity is then optimized using the left-right consistency test and disparity filling to obtain the final disparity map. The flow chart of the I-SGM algorithm is shown in Figure 1.

Improved Census Algorithm
The traditional Census transform relies too much on the central pixel point. When the central pixel point is disturbed by noise, the binary bit string obtained by the Census transform will significantly change, which is not conducive to maintaining the stability of algorithm performance [40]. In response, we redetermined the greyscale value of the reference pixel in order to improve its sensitivity to noise. In this paper, the greyscale values of neighboring pixels within the window are sorted, the maximum and minimum values are removed, and the average of the remaining pixel greyscale values is used as the greyscale value of the reference pixel. The improved equation is shown as below:

Improved Census Algorithm
The traditional Census transform relies too much on the central pixel point. When the central pixel point is disturbed by noise, the binary bit string obtained by the Census transform will significantly change, which is not conducive to maintaining the stability of algorithm performance [40]. In response, we redetermined the greyscale value of the reference pixel in order to improve its sensitivity to noise. In this paper, the greyscale values of neighboring pixels within the window are sorted, the maximum and minimum values are removed, and the average of the remaining pixel greyscale values is used as the greyscale value of the reference pixel. The improved equation is shown as below: where I(p) is the average grayscale value of the remaining pixels in the window after removing the maximum and minimum values, and I(q) is the grayscale value of each point in the window. The process of Census transformation is shown in Figure 2.
where I(p) is the average grayscale value of the remaining pixels in the window after removing the maximum and minimum values, and I(q) is the grayscale value of each point in the window. The process of Census transformation is shown in Figure 2. As shown in Figure 2a, under the 3 × 3 window of the conventional Census algorithm, the reference pixel is the center pixel, whose value is 120, and the binary string after Census transformation is 11101111. After the above improved calculation, the reference pixel value is 74 and the binary string after improved Census transformation is 011000011, as shown in Figure 2b. The improved Census algorithm effectively suppresses the luminance difference by eliminating the extreme values, increases the coding length, weakens the influence of the central pixel point, and reduces the mismatch rate generated when the central pixel point is mutated.

Adaptive Window Based on Connected Components
The choice of window size is a key issue in the cost calculation. To ensure a more accurate disparity estimate without affecting calculation speed, the window scale must also meet the requirements of including sufficient intensity changes to obtain reliable matching and avoiding the influence of interference information. This study proposes a method to select a suitable window based on image connected component information from adaptation. A connected component is a collection of pixels made up of neighboring pixels with the same pixel value. Each connected component in the image is found and marked, and the size of the Census transformation window is determined by the size of the connected component inside the window. The process of the adaptive window is specified as follows: (1) Set the initial window size to I × I, set the maximum window size to M × M, and set the initial number of connected components to T.  As shown in Figure 2a, under the 3 × 3 window of the conventional Census algorithm, the reference pixel is the center pixel, whose value is 120, and the binary string after Census transformation is 11101111. After the above improved calculation, the reference pixel value is 74 and the binary string after improved Census transformation is 011000011, as shown in Figure 2b. The improved Census algorithm effectively suppresses the luminance difference by eliminating the extreme values, increases the coding length, weakens the influence of the central pixel point, and reduces the mismatch rate generated when the central pixel point is mutated.

Adaptive Window Based on Connected Components
The choice of window size is a key issue in the cost calculation. To ensure a more accurate disparity estimate without affecting calculation speed, the window scale must also meet the requirements of including sufficient intensity changes to obtain reliable matching and avoiding the influence of interference information. This study proposes a method to select a suitable window based on image connected component information from adaptation. A connected component is a collection of pixels made up of neighboring pixels with the same pixel value. Each connected component in the image is found and marked, and the size of the Census transformation window is determined by the size of the connected component inside the window. The process of the adaptive window is specified as follows: (1) Set the initial window size to I × I, set the maximum window size to M × M, and set the initial number of connected components to T. The specific flow of the adaptive window algorithm is shown in Figure 3. The specific flow of the adaptive window algorithm is shown in Figure 3.

Cross-Based Cost Aggregation
The cost calculation only considers the correlation between neighborhood pixels, so for the subsequent calculation of disparity, the correlation between pixels needs to be described in more detail via cost aggregation. This paper introduces improved cross-based cost aggregation in the AD-Census algorithm [41]. Cross-based cost aggregation assumes that pixels of similar colors in the neighborhood have similar disparity values. If the disparity values of the pixels participating in the aggregation process are close, the reliability of the aggregation will be higher. Cross-based cost aggregation is to build a cross-arm with the center pixel as the origin. The length of the cross arm is dynamic, and its arm length stops when it encounters a large difference in color or brightness values from the center pixel.
The specific algorithm for the cross domain is shown in Equation (10): where p is the pixel to be matched; p1 is the new pixel; Dc (p1, p) is the difference between the color values of p1 and p; Ds (p1, p) is the arm length between p1 and p; L1, L2 are the thresholds for arm length; and τ1, τ2 are the thresholds for the difference between color values. In this paper, the threshold value is reset. Dc (p1, p) is set to the difference between the gray values of p1 and p; τ1, τ2 are set as the thresholds for the difference between the gray values.

Cross-Based Cost Aggregation
The cost calculation only considers the correlation between neighborhood pixels, so for the subsequent calculation of disparity, the correlation between pixels needs to be described in more detail via cost aggregation. This paper introduces improved cross-based cost aggregation in the AD-Census algorithm [41]. Cross-based cost aggregation assumes that pixels of similar colors in the neighborhood have similar disparity values. If the disparity values of the pixels participating in the aggregation process are close, the reliability of the aggregation will be higher. Cross-based cost aggregation is to build a cross-arm with the center pixel as the origin. The length of the cross arm is dynamic, and its arm length stops when it encounters a large difference in color or brightness values from the center pixel.
The specific algorithm for the cross domain is shown in Equation (10): where p is the pixel to be matched; p 1 is the new pixel; D c (p 1 , p) is the difference between the color values of p 1 and p; D s (p 1 , p) is the arm length between p 1 and p; L 1 , L 2 are the thresholds for arm length; and τ 1 , τ 2 are the thresholds for the difference between color values. In this paper, the threshold value is reset. D c (p 1 , p) is set to the difference between the gray values of p 1 and p; τ 1 , τ 2 are set as the thresholds for the difference between the gray values.
Cross-based growth (using horizontal as an example) must satisfy the following rules. If any of these rules are violated, the window stops growing.
(1) The gray difference between the point p to be matched and the new pixel p 1 , and the gray difference between the pixel to be added and the next pixel in this direction, are less than τ 1 . (2) The arm length D s (p 1 , p) of the point to be matched and the new pixel p 1 is less than the set arm length L 1 . (3) When the arm length D s (p 1 , p) of the point to be matched and the new pixel p 1 is greater than the set arm length L 2 , but less than the set arm length L 1 , and the gray difference between p 1 and p is less than the smaller threshold τ 2 .
The window growth rules are the same for the vertical orientation as for the horizontal orientation.
On the one hand, this can better find areas with small differences in gray values and limit the difference in growth to the next point, avoiding the window exceeding the image boundary. On the other hand, it ensures that larger windows are available in areas with weak textures, and areas of the right size are available in areas rich in texture.
When the cross-based window of pixel p is constructed, a cost aggregation is per formed. The aggregate generation value of pixel p can be obtained by accumulating the pixel generation value in the horizontal direction, adding this value to the vertical direction, and then accumulating the pixel generation value in the vertical direction.
In order to effectively reduce the mismatching rate in the depth discontinuities, four iterations are used in the cost aggregation. The first and third iterations grow the window first along the horizontal direction, and then along the vertical direction. The second and fourth iterations grow in the opposite direction. The smaller of the four iterations is taken as the cost aggregation value.

Experiment
The algorithms were written using the C++-OpenCV environment in the VisualStu-dio2017 development platform. The test hardware device was a CPU with 8G of RAM, and the operating system was Windows.

Validation Analysis of the I-SGM Algorithm
In order to verify the effectiveness of the I-SGM algorithm in this paper, experiments were carried out on pairs of images from existing datasets. Four sets of standard test images of Cones, Teddy, Tsukuba and Venus [23,42] were used. The experimental results are shown in Figure 4. Figure 4a shows the original left image of the four standard image pairs; Figure 4b shows the standard disparity map of the corresponding image; Figure 4c shows the disparity map obtained using the SGM algorithm; and Figure 4d shows the disparity map obtained using the I-SGM algorithm.
When comparing Figure 4c,d with the standard disparity map in Figure 4b, it can be seen that both algorithms have certain shortcomings, but the I-SGM algorithm is superior to the SGM algorithm. From the circled area in Figure 4c, it can be seen that the disparity map generated by the SGM algorithm has unclear contours, and the disparity effect is significantly poorer. From Figure 4d, it can be seen that the disparity maps generated by the I-SGM algorithm have clearer and more complete contours, with better continuity of grey levels at the edges of the image, and are closer to the standard disparity maps.
In order to further quantitatively verify the effectiveness of the I-SGM algorithm, the SAD algorithm, the SGM algorithm, and the I-SGM algorithm are compared and tested. Additionally, the matching speed and accuracy of each algorithm are compared in Table 1.
As can be seen from Table 1, the SAD algorithm requires the least running time, but the lowest matching accuracy. The I-SGM algorithm is superior to the SGM algorithm in terms of matching speed and accuracy. The data in Table 1 show that the I-SGM algorithm reduces the running time by an average of 1.41 s and increases the matching accuracy by an average of 6.12% compared to the SGM algorithm.
This paper also compares the objective performance metrics (SSIM, Perceptual Hash, PSNR, MSE) of the SGM algorithm and the I-SGM algorithm, as shown in Figures 5-8.  In order to further quantitatively verify the effectiveness of the I-SGM algorithm, the SAD algorithm, the SGM algorithm, and the I-SGM algorithm are compared and tested. Additionally, the matching speed and accuracy of each algorithm are compared in Table  1.   reduces the running time by an average of 1.41 s and increases the matching accuracy by an average of 6.12% compared to the SGM algorithm. This paper also compares the objective performance metrics (SSIM, Perceptual Hash, PSNR, MSE) of the SGM algorithm and the I-SGM algorithm, as shown in Figures 5-8.        From Figures 5 and 6, it can be seen that the I-SGM algorithm has a higher Structure Similarity Index Measure (SSIM) than the SGM algorithm, while the Hamming distance value obtained using the Perceptual Hash (pHash) algorithm is smaller than that of the SGM algorithm. This indicates that the disparity maps obtained using the I-SGM algorithm are more similar to the standard maps. In Figure 7, the Peak Signal-to-Noise Ratio (PNSR) of the SGM algorithm is significantly lower than that of the I-SGM algorithm. This indicates that the I-SGM algorithm obtains disparity maps with less noise and is able to improve noise immunity. As can be seen in Figure 8, the Mean Square Error (MSE) of the SGM algorithm is much larger than that of the I-SGM algorithm. This result indicates that the quality of the disparity maps obtained by the I-SGM algorithm is better than that of the SGM algorithm.

Analysis of Noise Immunity
To further verify the robustness of the I-SGM algorithm against noise, the disparity map was analyzed for noise immunity. The algorithm was compared with the SGM algorithm. Salt and pepper noise was added to the test image cones, with noise densities of 2%, 4%, 6% and 8%, respectively. The disparity maps are shown in Figure 9. The matching rates are shown in Table 2  From Figures 5 and 6, it can be seen that the I-SGM algorithm has a higher Structure Similarity Index Measure (SSIM) than the SGM algorithm, while the Hamming distance value obtained using the Perceptual Hash (pHash) algorithm is smaller than that of the SGM algorithm. This indicates that the disparity maps obtained using the I-SGM algorithm are more similar to the standard maps. In Figure 7, the Peak Signal-to-Noise Ratio (PNSR) of the SGM algorithm is significantly lower than that of the I-SGM algorithm. This indicates that the I-SGM algorithm obtains disparity maps with less noise and is able to improve noise immunity. As can be seen in Figure 8, the Mean Square Error (MSE) of the SGM algorithm is much larger than that of the I-SGM algorithm. This result indicates that the quality of the disparity maps obtained by the I-SGM algorithm is better than that of the SGM algorithm.

Analysis of Noise Immunity
To further verify the robustness of the I-SGM algorithm against noise, the disparity map was analyzed for noise immunity. The algorithm was compared with the SGM algorithm. Salt and pepper noise was added to the test image cones, with noise densities of 2%, 4%, 6% and 8%, respectively. The disparity maps are shown in Figure 9. The matching rates are shown in Table 2.   From Figure 9 and Table 2, it can be seen that the matching effect of the I-SGM algorithm is better than that of the SGM algorithm under a noise density of 0-8%, and the matching rate is higher. The matching rate of I-SGM algorithm fluctuates less under the influence of less noise, while the matching rate of the SGM algorithm is slightly different. With the increase in noise density, the matching rate of the disparity map under different algorithms decreases, but the decrease in the I-SGM algorithm is less than that of SGM algorithm, which shows that the I-SGM algorithm has better robustness against the influence of noise.

Experiments in a Simulated Lunar Surface Environment
The I-SGM algorithm is implemented based on a lunar surface environment, so the experiment was carried out in the simulated Lunar Experiment Module at Southeast University to verify the practical feasibility of the algorithm. In the Lunar Experiment Module, simulated lunar soil was used to pave the floor of the module, and stones were used to simulate moon rocks. The model for simulating lunar soil is CAS-1, which is developed and produced by the Chinese Academy of Sciences. The material composition and mechanical properties of the simulant are similar to those of the lunar soil sampled from the Apollo 14 landing site [43]. The images in the simulated environment acquired using the binocular camera are shown in Figure 10a (exemplified by the left image). The obtained disparity maps are shown in Figure 10b,c. From Figure 10b,c, it can be seen that both the SGM algorithm and I-SGM algorithm can display the contours of obstacles, but it is obvious that the contours of obstacles are clearer in the disparity map obtained using the I-SGM algorithm. As the light becomes weaker, the edges of the obstacle contour can still be clearly seen in the disparity map obtained using the I-SGM algorithm, while the contour of the obstacle is not clear in the disparity map obtained using the SGM algorithm.

Conclusions
In summary, this paper focuses on the SGM algorithm and proposes the I-SG rithm to address the problems of low matching accuracy and weak noise immunit SGM algorithm. Firstly, the Census algorithm, which has more robustness to illum changes, is used in cost calculation to replace the original mutual information-ba calculation. Meanwhile, the Census algorithm is improved by re-determining th ence pixel value, which improves the problem of the original algorithm relying to on the central pixel value, effectively reduces the influence of noise on the algorith improves the noise immunity. Secondly, in order to solve the problem of the fixed gular window of the original Census algorithm affecting its matching rate, an im idea of an adaptive window based on the data of connected components is pr which can reduce the running time of the algorithm. Finally, Cross-based cost aggr in the AD-Census algorithm is used in cost aggregation to improve the accurac algorithm.
Algorithm validation experiments were conducted on the standard test ima provided by the Middleburry website, and comparative analysis revealed that, co

Conclusions
In summary, this paper focuses on the SGM algorithm and proposes the I-SGM algorithm to address the problems of low matching accuracy and weak noise immunity in the SGM algorithm. Firstly, the Census algorithm, which has more robustness to illumination changes, is used in cost calculation to replace the original mutual information-based cost calculation. Meanwhile, the Census algorithm is improved by re-determining the reference pixel value, which improves the problem of the original algorithm relying too much on the central pixel value, effectively reduces the influence of noise on the algorithm, and improves the noise immunity. Secondly, in order to solve the problem of the fixed rectangular window of the original Census algorithm affecting its matching rate, an improved idea of an adaptive window based on the data of connected components is proposed, which can reduce the running time of the algorithm. Finally, Cross-based cost aggregation in the AD-Census algorithm is used in cost aggregation to improve the accuracy of the algorithm.
Algorithm validation experiments were conducted on the standard test image pairs provided by the Middleburry website, and comparative analysis revealed that, compared to the SGM algorithm, the I-SGM algorithm reduced the execution time by an average of 1.41 s and increased matching accuracy by an average of 6.12% for all examined image sets. This paper also validates the noise immunity of the I-SGM algorithm and compares it with the SGM algorithm. Under the interference of salt and pepper noise, the matching effect of the I-SGM algorithm is significantly better than that of the SGM algorithm. As the noise density increases, the matching rate of the I-SGM algorithm also decreases less significantly than that of the SGM algorithm. The experimental results demonstrate that the I-SGM algorithm can improve matching speed and accuracy, effectively reduce the effects of noise on images, and achieve superior matching outcomes. By further applying the I-SGM algorithm to the simulated lunar environment, it is found that the I-SGM algorithm can better help lunar exploration equipment detect obstacles encountered while travelling on the lunar surface, which has a complex terrain and dim light. The I-SGM algorithm improved matching accuracy, but the improvement in computation time was not very satisfactory. In future studies, deep learning techniques can be introduced and combined with the stereo matching algorithm to train a suitable model to improve matching efficiency.